package com.cssw.fyzb.tps.service.sms;

import com.cssw.fyzb.tps.config.sms.SmsConfiguration;
import com.cssw.fyzb.tps.service.sms.adapter.SmsAdapter;
import com.cssw.fyzb.tps.service.sms.adapter.SmsAdapterFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author Feng Chen
 */
@Component
public class AimSms {

    @Autowired
    private SmsAdapter smsAdapter;

    private static final Logger logger = LoggerFactory.getLogger(AimSms.class);

    public AimSms(SmsConfiguration configuration) {
        if (configuration == null) {
            throw new IllegalArgumentException("Configuration must not be null");
        }
        this.smsAdapter = SmsAdapterFactory.createSmsAdapter(configuration);
    }

    public void send(String mobile, String message) throws Exception {
        smsAdapter.send(mobile, message);
    }

    public void send(String mobile, String signName, String code, String templateCode) throws Exception {
        smsAdapter.send(mobile, signName, code, templateCode);
    }

}
